import java.awt.Color;

	/**************************************** 
	*  Submitted by:                        *   
	*                                       *
	*  Michael Fildstein, ID: 309161594     *  
	*  Tomer Ben Rachel, ID: 021982475      *
	*   				                          	*
	*****************************************/  

//This program draws a snowflake on the screen by calling the function drawSnowflake recursively.
//Which in turn, draws a basic star that each time is different only by it's smaller size and location.

public class Snowflake {
	
	public static void main(String args[]) {
        Painter.draw("Snowflake");
    }

	public static void draw() { 
		int height = Painter.getFrameHeight()/2;
		int width = Painter.getFrameWidth()/2;
		int maxRadius = Math.min(height, width)/2;
		int size = maxRadius/4; 		
		Painter.setColor(Color.blue);
		drawSnowflake(height, width, size,4);  //Call to recursive function
		}
	
   
  //The function drawSnowflake draws a basic star on the screen 
	public static void drawSnowflake (int x, int y, int size ,int depth) {
		if (depth != 0){
			for (int i = 0; i<6; i++) {
				int endX = x + (int)(size*Math.cos(2*Math.PI/6*i));
				int endY = y - (int)(size*Math.sin(2*Math.PI/6*i )); 
				drawSnowflake(endX, endY, size/3, depth - 1);
				Painter.drawLine(x, y, endX, endY);
			}
		}	
	}
}
